package com.zhrd.bussinss.platform.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;

import com.zhrd.bussinss.platform.bo.UserApplyInfo;
import com.zhrd.bussinss.platform.dao.BbtangHomeDao;

@Repository("bbtangHomeDao")
public class BbtangHomeDaoImpl implements BbtangHomeDao {

	@Autowired
	NamedParameterJdbcTemplate namedParameterJdbcTemplate;

	@Override
	public int save(UserApplyInfo info) {
		String sql = "INSERT INTO user_apply_info (username,contact,major,school,"
				+ "info,createtime)"
				+ "VALUES (:username,:contact,:major,:school,:info,:createtime)";
		SqlParameterSource paramSource = new BeanPropertySqlParameterSource(info);
		KeyHolder keyHolder = new GeneratedKeyHolder();
		namedParameterJdbcTemplate.update(sql, paramSource, keyHolder);
		return keyHolder.getKey().intValue();
	}
	
	
//	@Override
//	public int save(FamilyInfo f) {
//		String sql = "INSERT INTO family_info (family_code,family_address,family_createtime,family_updatetime,"
//				+ "family_status,family_contract1,family_contract2,family_member,family_community_code) "
//				+ "VALUES (:familyCode,:familyAddress,:familyCreatetime,:familyUpdatetime,:familyStatus,:familyContract1,:familyContract2,:familyMember,:familyCommunityCode)";
//		SqlParameterSource paramSource = new BeanPropertySqlParameterSource(f);
//		KeyHolder keyHolder = new GeneratedKeyHolder();
//		namedParameterJdbcTemplate.update(sql, paramSource, keyHolder);
//		return keyHolder.getKey().intValue();
//	}
}
